const result = require('./handle.js')
const abnormal = async (ctx, next) => {
  try {
    await next()
  } catch (error) {
    const isResult = error instanceof result
    if (isResult) {
      ctx.body = {
        msg: error.msg,
      }
      ctx.status = error.code
    } else {
           ctx.body = {
        msg:"服务器发生错误"
      }
      ctx.status = "500"
    }
  }
}
module.exports=abnormal